package com.itheima.sc.service.ums;

import com.itheima.sc.api.ums.UmsResourceApi;
import com.itheima.sc.pojo.ums.UmsResource;
import com.itheima.sc.vo.PageResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UmsResourceService {
    @DubboReference
    private UmsResourceApi umsResourceApi;

    /**
     * 添加后台资源
     */
    public void create(UmsResource umsResource) {
        umsResource.setCreateTime(new Date());
        //添加后台资源
        umsResourceApi.create(umsResource);
    }

    /**
     * 根据ID删除后台资源
     */
    public void delete(Integer id) {
        // 根据ID删除后台资源
        umsResourceApi.delete(id);
    }

    /**
     * 分页模糊查询后台资源
     */
    public PageResult list(Integer pageNum, Integer pageSize, Integer categoryId, String nameKeyword, String urlKeyword) {
        return umsResourceApi.list(pageNum, pageSize, categoryId, nameKeyword, urlKeyword);
    }

    /**
     * 查询所有后台资源
     */
    public List<UmsResource> listAll() {
        return umsResourceApi.listAll();
    }

    /**
     * 根据ID获取资源详情
     */
    public UmsResource getInfoById(Integer id) {
        return umsResourceApi.getInfoById(id);
    }

    /**
     * 修改后台资源
     */
    public void update(UmsResource umsResource) {
        umsResourceApi.update(umsResource);
    }
}
